<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<div id="update_modal" class="easyui-window" title="修改密码"
		data-options="modal:true,closed:true,maximizable:false,
	    minimizable:false"
		style="width: 500px; padding: 10px;">
			<div data-options="region:'north'">
			<form id='update_password_form' method="post">
				<table style="margin: auto;">
				
					<tr>
						<td><label for="name">当前密码:</label></td>
						<td><input class="easyui-textbox"
							type="password" name="originalPassword"
							data-options="required:true,missingMessage:'请输入密码'" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td><label for="name">密&nbsp;&nbsp;码:</label></td>
						<td><input id="password" class="easyui-textbox"
							type="password" name="login_password"
							data-options="required:true,missingMessage:'请输入密码'" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>

					<tr>
						<td><label for="name">重复密码:</label></td>
						<td><input class="easyui-textbox" type="password"
							name="repassword" data-options="required:true"
							validType="equalTo['#password']" /></td>
					</tr>
					<tr>
						<td></td>
						<td></td>
					</tr>
				</table>
			</form>
		</div>
		<div data-options="region:'center'" style="text-align: center">
			<br /> <a id="update_password_btn" href="javascript:void(0);"
				class="easyui-linkbutton" data-options="iconCls:'icon-ok'">修改</a>
		</div>	
		
</div>

<script>
	$.extend($.fn.validatebox.defaults.rules, {
		/*必须和某个字段相等*/
		equalTo : {
			validator : function(value, param) {
				return $(param[0]).val() == value;
			},
			message : '两次输入不一致'
		}
	});
	
	
	$("#update_password_btn").click(function() {
		$("#update_password_form").form('submit', {
			url : "customer/user/update_password",
			dataType : 'json',//无效？？？
			onSubmit : function() {
				var isValid = $(this).form('validate');
				return isValid;
			},

			success : function(data) {
				//$.messager.alert('提示信息', data);
				var data = eval("(" + data + ")");
				if (data.success == true) {
					$('#update_modal').window('close');
				}
				$.messager.alert('提示信息', data.msg);
			}
		});
	});
</script>